//
//  HYYMessageCell.m
//  linktuIOS
//
//  Created by hejunsong on 2016/11/19.
//  Copyright © 2016年 tianxie. All rights reserved.
//

#import "HYYMessageCell.h"
#import "YYLabel.h"
#import "YYImage.h"
#import "YYText.h"
#import "HLiveMesssage.h"
@interface HYYMessageCell()

@property(nonatomic,strong) YYLabel *contentLable;
@end


@implementation HYYMessageCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        _contentLable = [YYLabel new];
        _contentLable.numberOfLines = 0;
        _contentLable.frame = CGRectMake(0, 0, 0, 0);
        _contentLable.backgroundColor = [UIColor clearColor];
        
        self.contentView.backgroundColor = [UIColor clearColor];
        self.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:_contentLable];
        
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}

-(void)setMessage1:(LTMessage *)message1
{
    _message1 = message1;
    LTMessageTextBody *body = message1.body;
    self.contentLable.text = body.text;
    
}

-(void)setMessgae:(HLiveMesssage *)messgae
{
    _messgae = messgae;
    self.contentLable.attributedText = messgae.ccntentString;
    self.contentLable.size = messgae.layout.textBoundingSize;
    // 4. 接受事件回调
    kSelfWeak;
    _contentLable.highlightTapAction = ^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect) {
        NSLog(@"tap text range:...");
        if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(hyyMessageCellWithuserID:)])
        {
            [weakSelf.delegate hyyMessageCellWithuserID:weakSelf.messgae.message.since];
        }
        
    };

}


@end
